package com.jz.jingying.utils;


import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat;

public class NumberTools {

	private static class SingletonHolder {
		private static NumberTools INSTANCE = new NumberTools();
	}

	public static NumberTools getInstance() {
		return SingletonHolder.INSTANCE;
	}
	
	public boolean isNumeric2(String str){
		for (int i = str.length();--i>=0;){
		   if (!Character.isDigit(str.charAt(i))){
		    return false;
		   }
		}
		return true;
	}
	
	public String decimalFormat(int number,int length){
		String num = String.valueOf(number);
		StringBuilder zeros = new StringBuilder();
		for(int i = 0; i < length; i++){
			zeros.append("0");
		}
		if(zeros.length() > 0){
			NumberFormat nf = new DecimalFormat(zeros.toString());
			num = nf.format(number);
		}
		return num;
	}
	
	public byte[] getByte(byte[] value) throws IOException {
		byte[] c = null;
		if(null != value){
			java.io.ByteArrayInputStream bin = new java.io.ByteArrayInputStream(value);
			try {
				java.io.DataInputStream in = new java.io.DataInputStream(bin);
				try {
					in.readUTF();
					in.readUTF();
					in.readInt();
					c = new byte[in.available()];
					in.read(c, 0, c.length);
				} finally {
					in.close();
				}
			} finally {
				bin.close();
			}
		}
		return c;
	}
	
	public int getNationNO(String nation){
		int i = 1;
		if("��".equals(nation)){ i = 1;
		}else if("�ɹ�".equals(nation)){ i = 2;
		}else if("��".equals(nation)){ i = 3;
		}else if("��".equals(nation)){ i = 4;
		}else if("ά���".equals(nation)){ i = 5; 
		}else if("��".equals(nation)){ i = 6;
		}else if("��".equals(nation)){ i = 7;
		}else if("׳".equals(nation)){ i = 8;
		}else if("����".equals(nation)){ i = 9;
		}else if("����".equals(nation)){ i = 10;
		}else if("��".equals(nation)){ i = 11;
		}else if("��".equals(nation)){ i = 12;
		}else if("��".equals(nation)){ i = 13;
		}else if("��".equals(nation)){ i = 14;
		}else if("����".equals(nation)){ i = 15;
		}else if("����".equals(nation)){ i = 16;
		}else if("������".equals(nation)){ i = 17;
		}else if("��".equals(nation)){ i = 18;
		}else if("��".equals(nation)){ i = 19;
		}else if("����".equals(nation)){ i = 20;
		}else if("��".equals(nation)){ i = 21;
		}else if("�".equals(nation)){ i = 22;
		}else if("��ɽ".equals(nation)){ i = 23;
		}else if("����".equals(nation)){ i = 24;
		}else if("ˮ".equals(nation)){ i = 25;
		}else if("����".equals(nation)){ i = 26;
		}else if("����".equals(nation)){ i = 27;
		}else if("����".equals(nation)){ i = 28;
		}else if("�¶�����".equals(nation)){ i = 29;
		}else if("��".equals(nation)){ i = 30;
		}else if("���Ӷ�".equals(nation)){ i = 31;
		}else if("����".equals(nation)){ i = 32;
		}else if("Ǽ".equals(nation)){ i = 33;
		}else if("����".equals(nation)){ i = 34;
		}else if("����".equals(nation)){ i = 35;
		}else if("ë��".equals(nation)){ i = 36;
		}else if("����".equals(nation)){ i = 37;
		}else if("����".equals(nation)){ i = 38;
		}else if("����".equals(nation)){ i = 39;
		}else if("����".equals(nation)){ i = 40;
		}else if("������".equals(nation)){ i = 41;
		}else if("ŭ".equals(nation)){ i = 42;
		}else if("���α��".equals(nation)){ i = 43;
		}else if("����˹".equals(nation)){ i = 44;
		}else if("���¿�".equals(nation)){ i = 45;
		}else if("�°�".equals(nation)){ i = 46;
		}else if("����".equals(nation)){ i = 47;
		}else if("ԣ��".equals(nation)){ i = 48;
		}else if("��".equals(nation)){ i = 49;
		}else if("������".equals(nation)){ i = 50;
		}else if("����".equals(nation)){ i = 51;
		}else if("���״�".equals(nation)){ i = 52;
		}else if("����".equals(nation)){ i = 53;
		}else if("�Ű�".equals(nation)){ i = 54;
		}else if("���".equals(nation)){ i = 55;
		}else if("��ŵ".equals(nation)){ i = 56;
		}
		return i;
	}
}
